package com.xuecheng.content.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// 创建交换机、队列和绑定
@Configuration
public class MQConfiguration {

    // 创建队列
    @Bean
    public Queue contentQueue() {
        return new Queue("content.queue");
    }

    // 创建交换机
    @Bean
    public TopicExchange contentExchange() {
        return new TopicExchange("content-exchange");
    }


    // 队列绑定交换机
    @Bean
    public Binding contentQueueBindContentExchange(Queue contentQueue,TopicExchange contentExchange){
        return  BindingBuilder.bind(contentQueue).to(contentExchange).with("course.pub");
    }
}
